{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">语言管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
            <script type="text/html" id="commonTpl">
                {{# if(d.common==1){ }}
               是
                {{#  } else { }}
               否
                {{#  } }}
            </script>
            <script type="text/html" id="icon">
                {{# if(d.mark ==0){ }}无
                {{#  } else { }}
                <div><img class="site-icon" src="/static/lang/image/{{d.mark}}.png" alt=""></div>
                {{#  } }}
            </script>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        add_url: "{:url('add')}",
        edit_url: "{:url('edit')}",
        delete_url: "{:url('del')}",
        modify_url: '{:url("multi")}',
    };

    table.render({
        init: init,
        toolbar: ['refresh','add'],
        url: '{:url("index")}',
        cols: [
            [
                { field: 'id', width: 80, title: 'ID'},
                { field: 'name', width: 120, title: '语言名称'},
                { field: 'mark', title: '语言标识'},
                { field: 'logo', width: 150, title: '语言图标', align: "center", search: false, templet: '#icon'},
                { field: 'common', align: 'center', width: 120, title: '常用语言', templet: '#commonTpl', unresize: true },
                { field: 'status', width: 120, align: "center", title: '状态', unresize: true, selectList: { 0: '禁用', 1: '正常' },templet: yznTable.formatter.switch,tips:"正常|禁用" },
                { width:100, title: '操作', align: "center", templet: function (d){
                        if(d.id==1){
                            return '<a class="layui-btn layui-btn-xs layui-btn-danger layui-btn-disabled"><i class=\'iconfont icon-brush_fill\'></i></a><a class="layui-btn layui-btn-xs layui-btn-danger layui-btn-disabled"><i class=\'iconfont icon-trash_fill\'></i></a>';
                        }else{
                            return yznTable.formatter.tool.call(this,d,this);
                        }
                    },operat: ['edit','delete']}
            ]
        ],
        page: {}
    });
    
    yznTable.bindevent();
});
</script>
{/block}